﻿
	//检测机构证件号码是否正确
	jQuery.validator.addMethod("certIdValidate", function(value) {
		var result = true;
		if($("#certType").val() == "73"){
			if($.trim(value).length != 18){
				result = false;
			}
		}
		if($("#certType").val() == "52"){
			var reg = /^([0-9A-Z]){8}-[0-9|X]$/;
			if (!reg.test($.trim(value))) {
				result = false;
			}
		}
		return result;
	}, "请输入有效的机构证件号码");

	//检测身份证号是否正确
	jQuery.validator.addMethod("idValidate", function(value) {
		var result = true;
		var proxyCertTypeValue = $("#proxyCertType").val();
		if(proxyCertTypeValue == "1"){
			result = IdentityCodeValid(value);
		}
		return result;
	}, "请输入有效的身份证号码");

	//检测身份证号是否正确
	jQuery.validator.addMethod("legalIdValidate", function(value) {
		var result = true;
		var legalCertTypeValue = $("#legalCertType").val();
		if(legalCertTypeValue == "1"){
			result = IdentityCodeValid(value);
		}
		return result;
	}, "请输入有效的身份证号码");

	//检测是否勾选开通业务类型
	jQuery.validator.addMethod("authValidate", function() {
		var flag = true;
		var obj = document.getElementsByName("auth");
		for (var i = 0; i < obj.length; i++) {
			if (obj[i].checked == 'checked') {
				flag = false;
				break;
			}
		}
		return flag;
	}, "请选择要开通的业务类型");

	//检测手机号是否正确
	jQuery.validator.addMethod("mobileValidate", function(value) {
		var result = true;
		var mobileReg = /^(((13[0-9]{1})|(14[0-9]{1})|(15[0-9]{1})|(17[0-9]{1})|(18[0-9]{1}))+\d{8})$/;
		if (!mobileReg.test(value)){
			result = false;
		}
		return result;
	}, "请输入有效的手机号码");

	jQuery.validator.addMethod("regFundValidate", function(value) {
		var result = true;
		if(value == null || value == ""){
			return result;
		}
		var regex = new RegExp("(^\\d{1,13}\\.\\d{1,2}$)|(^\\d{1,14}$)");
		var amt = value.replace(/,/g,"");
		if(!regex.test(amt) || amt<=0 || amt>=10000000000000){
			result=false;
		}
		return result;
	}, "输入金额有误，请重新输入");

	//检测电子邮箱是否正确
	jQuery.validator.addMethod("emailValidate", function(value) {
		var result = true;
		var emailReg = /(^[a-zA-Z0-9_-]+@[a-zA-Z0-9_-]+\.[a-zA-Z0-9_-]+$)|(^$)/;
		if (!emailReg.test(value)){
			result = false;
		}
		return result;
	}, "请输入有效的电子邮箱");

	//检测省市信息
	jQuery.validator.addMethod("areaCityValidate", function(value,element) {
		var result = true;
		var aVal = $(element).prev('select').val();
		var dVal = $(element).next('input').val();
		if (isSpace(value) || isSpace(aVal) || isSpace(dVal)){
			result = false;
		}
		return result;
	}, "这是必填字段");

	//检测字段是否含有特殊字符
	jQuery.validator.addMethod("specialCharValidate", function(value) {
		var result = true;
		var patrn=/[`~!@#$%^&*()_+<>:"{}.\/'[\]]/im;
		if(patrn.test(value)){
			result = false;
		}
		return result;
	}, "含有非法字符！");

	//检测字段是否超长
	jQuery.validator.addMethod("lengthValidate", function(value,element,len) {
		var result = true;
		var facLen = getStrLength(value);
		if(facLen > len){
			result = false;
		}
		return result;
	}, "内容长度不合法");

	/**发布背书的检测**/
		//检测会员编号是否正确
	jQuery.validator.addMethod("enddMemberNoValidate", function(value) {
		var result = true;
		if(value == $("#memberNo").text()){
			result = false;
		}
		return result;
	}, "无法给自己发布背书，请重新输入");

	//检测利率是否正确
	jQuery.validator.addMethod("rateValidate", function(value) {
		var result = true;
		value = value.replace(/,/g,"");
		var reg = new RegExp("(^\\d{1,4}\\.\\d{1,7}$)|(^\\d{1,4}$)");
		if(value.indexOf("0") == 0 || !reg.test(value)){
			result = false;
		}
		return result;
	}, "利率输入有误");
	//检测利率是否合法
	jQuery.validator.addMethod("rateValValidate", function(value) {
		var result = true;
		value = value.replace(/,/g,"");
		value = parseFloat(value);
		if(value <= 0){
			result = false;
		}
		return result;
	}, "利率输入有误");
	//检测开户行行号长度是否正确
	jQuery.validator.addMethod("bankCodeLengthValidate", function(value) {
		var result = true;
		if(value.length > 0){
			if(value.length != 12){
				result = false;
			}
		}
		return result;
	}, "行号位数不对，请重新输入");
	jQuery.validator.addMethod("spareTmValidate", function(value) {
		var result = true;
		if(value.length > 0){
			var text = /^(\+|-)?\d+$/;
			if (!(text.test(value))) {
				return false;
			}
		}
		return result;
	}, "剩余期限输入不合法，请重新输入");
	jQuery.validator.addMethod("spareTmLenValidate", function(value) {
		var result = true;
		if(value.length > 0){
			if ( value > 365) {
				return false;
			}
		}
		return result;
	}, "剩余期限超过票据允许最大期限，请重新输入");
	//检测金额是否正确
	jQuery.validator.addMethod("amountValidate", function(value) {
		var result = true;
		if(!isSpace(value)){
			value = value.replace(/,/g,"");
			var reg = new RegExp("(^\\d{1,13}\\.\\d{1,2}$)|(^\\d{1,13}$)");
			if(!reg.test(value)){
				result = false;
			}
		}
		return result;
	}, "输入金额有误");
	//检测金额是否超额
	jQuery.validator.addMethod("amtValidate", function(value) {
		var result = true;
		if(!isSpace(value)){
			value = value.replace(/,/g,"");
			value = parseFloat(value);
			if(value >= 10000000000000 || value <= 0){
				result = false;
			}
		}
		return result;
	}, "输入金额有误");
	//到期日检测，大于今天
	jQuery.validator.addMethod("deadlineDtValidate", function(value) {
		var result = true;
		var today = getNowFormatDate();
		var valDt = new Date(value.replace(/-/g,"/"));
		var todayDt = new Date(today.replace(/-/g,"/"));
		if(valDt - todayDt < 0){
			result = false;
		}
		return result;
	}, "日期不可早于当天，请重新输入");
	//日期必须小于今天
	jQuery.validator.addMethod("beforeDtValidate", function(value) {
		var result = true;
		var today = getNowFormatDate();
		var valDt = new Date(value.replace(/-/g,"/"));
		var todayDt = new Date(today.replace(/-/g,"/"));
		if(valDt - todayDt > 0){
			result = false;
		}
		return result;
	}, "日期不可晚于当天，请重新输入");
	//挂牌公告期
	jQuery.validator.addMethod("listingPeriodValidate", function(value) {
		var result = true;
		if(value.length > 0){
			var text = /^(\+|-)?\d+$/;
			if (!(text.test(value))) {
				result = false;
			}
			value = parseFloat(value);
			if(value <= 0){
				result = false;
			}
		}
		return result;
	}, "挂牌公告期输入不合法，请重新输入");



